import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n = 0, max = 0, p = 0;
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter size of array:");
        int res = -1;
        n = scan.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            System.out.println("Enter arr[" + i + "]:");
            arr[i] = scan.nextInt();
            max = max < arr[i] ? i : max;
        }
        System.out.println("Enter even position:");
        p = scan.nextInt();
        if (arr[p] % 2 == 0) {
            res = arr[p];
            for (int i = p; i < max - 1; i++) {
                res = res > arr[i] ? arr[i] : res;
            }
            res = res == arr[p] ? -1 : res;
        }
        System.out.println(res);
    }
}